<?php include  APP_PATH.'../template/public/header.php'?>
<aside class="main-sidebar">
    <section class="sidebar">
        <?php include APP_PATH.'../template/public/navigation.php'?>
    </section>
</aside>
<div class="content-wrapper">
    <section class="content-header">
        <h1>
            {$title}
            <a href="{:url('add_adv_plan')}" class="btn  btn-primary"><i class="fa fa-fw fa-plus"></i>新建广告计划</a>
        </h1>

        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> {$title}</a></li>
        </ol>
    </section>
    <section class="content">
        <div class="box">
            <div class="box-body">
                <div class="input-daterange input-group">

                    <form style="margin-left: 10px;float: left"class="layui-form" action="">
                        <input id="test" v="0" type="checkbox" name="close" lay-skin="switch" lay-filter="switchTest" lay-text="是|否"><label >是否显示数据</label>&nbsp;
                    </form>
                </div>
                <table id='table'
                       data-url="{:url('adv_plan_list')}"
                       data-toggle="table"
                       data-show-refresh="true"
                       data-show-toggle="true"
                       data-show-columns="true"
                       data-search="true"
                       data-pagination="true"
                       data-query-params="queryParams"
                       data-advanced-search="true"
                       data-side-pagination="server"
                       data-select-item-name="worker_picker"
                       data-show-export="true"
                       data-click-to-select="true"
                       data-toolbar="#toolbar"
                       data-sort-name="name"
                       data-sort-order="desc">
                    <div class="bars pull-left">
                        <div id="toolbar">

                        </div>
                    </div>
                    <thead>
                    <tr>
                        <th data-field="plan_name"  data-align="left" data-sortable="true" >广告计划</th>
                        <th data-field="plan_code"   data-align="left">广告计划ID</th>
                        <th data-field="operation"  data-align="left" >操作</th>
                        <th data-field="audit_state"  data-align="center">当前状态</th>
                        <th data-field="audit_note"  data-align="center">审核备注</th>
                        <th data-field="attr_adv_group_name"   data-align="left">广告组</th>
                        <th data-field="attr_adv_user_name"   data-align="left">广告主</th>
                        <th data-field="platform"   data-align="left">投放平台</th>
                        <th data-field="style"   data-align="left">广告样式</th>
                        <th data-field="system"   data-align="left">投放系统</th>
                        <th data-field="put_start_time"   data-align="left">投放开始时间</th>
                        <th data-field="put_end_time"   data-align="left">投放结束时间</th>
                        <th data-field="budget_type"   data-align="left">预算类型</th>
                        <th data-field="budget_amoont"   data-align="left">广告预算</th>
                        <th data-field="pay_amount"   data-align="left">出价</th>
                        <th data-field="pay_type"   data-align="left">收费方式</th>
                        <th data-field="put_location"   data-align="left">投放位置</th>
                        <th data-field="num_show"   data-align="left">曝光量</th>
                        <th data-field="num_click"   data-align="left">点击量</th>
                        <th data-field="click_rate"   data-align="left">点击率</th>
                        <th data-field="CPM"   data-align="left">CPM</th>
                        <th data-field="CPC"   data-align="left">CPC</th>
                        <th data-field="sum_amount"   data-align="left">消耗金额(元)</th>
                    </tr>

                    </thead>
                    <tbody>

                    </tbody>
                </table>
            </div>
        </div>
    </section>
</div>
<?php include APP_PATH.'../template/public/footer.php'; ?>
<script>
    layui.use(['form', 'layedit', 'laydate'], function() {
        $('.select2').select2();
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;
        form.on('switch(switchTest)', function(data){
            var state=(this.checked ? '1' : '0');
            $("#test").attr('v',state);
            $('#table').bootstrapTable("refresh");
        });
    });
    function queryParams(params) {
        return {
            limit: params.limit,
            offset: params.offset,
            search:$('.search input[type="text"]').val(),
            name: params.sort,
            order: params.order,
            state:$('#test').attr('v'),
        };
    }
    function del_adv_plan(id) {
        var loading = layer.load(1, {shade: [0.1, '#fff']});
        $.get("{:url('del_adv_plan')}?id="+id,function (res) {
            layer.close(loading);
            if (res.code > 0) {
                layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                    var loading = layer.load(1, {shade: [0.1, '#fff']});
                    $('#table').bootstrapTable("refresh");
                    layer.close(loading);
                });
            } else {
                layer.msg(res.msg, {time: 1800, icon: 2});
            }

        });
    }
</script>
</html>